package de.akad.imp03.client.data;

import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.Label;

public class Rundendaten {
	private final static String DEFAULT_NAME = "Mr. X";
	private final static int START_BUDGET = 1000;
	private final static int START_SEC = 600;
	public final static int NONE = -1;
	public final static int FACEBOOK = 0;
	public final static int WEBSITE = 1;
	public final static int STEPSTONE = 2;
	public final static int TWITTER = 3;
	public final static int XING = 4;
	public final static int HEADHUNTER = 5;

	
	private String name;
	private int budget;  // in EUR
	private int restzeit; // in Sekunden
	private Label budgetLabel;
	private Label timeLabel;
	private int selectedItem = NONE;

	public Rundendaten() {
		this(DEFAULT_NAME);
	}
	
	public Rundendaten(String name) {
		this.name = DEFAULT_NAME;
		budget = START_BUDGET;
		restzeit = START_SEC;
	}
	

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the budget
	 */
	public int getBudget() {
		return budget;
	}

	/**
	 * @param budget the budget to set
	 */
	public void setBudget(int budget) {
		this.budget = budget;
	}

	/**
	 * @return the restzeit
	 */
	public int getRestzeit() {
		return restzeit;
	}

	/**
	 * @param restzeit the restzeit to set
	 */
	public void setRestzeit(int restzeit) {
		this.restzeit = restzeit;
	}

	/**
	 * @return the budgetLabel
	 */
	public Label getBudgetLabel() {
		return budgetLabel;
	}

	/**
	 * @param budgetLabel the budgetLabel to set
	 */
	public void setBudgetLabel(Label budgetLabel) {
		this.budgetLabel = budgetLabel;
	}

	/**
	 * @return the timeLabel
	 */
	public Label getTimeLabel() {
		return timeLabel;
	}

	/**
	 * @param timeLabel the timeLabel to set
	 */
	public void setTimeLabel(Label timeLabel) {
		this.timeLabel = timeLabel;
	}
	
	/**
	 * @return the selectedItem
	 */
	public int getSelectedItem() {
		return selectedItem;
	}

	/**
	 * @param selectedItem the selectedItem to set
	 */
	public void setSelectedItem(int selectedItem) {
		this.selectedItem = selectedItem;
	}

	private String getTimeAsString() {
		String result = "" + getRestzeit();
		return result;
	}
	
	public void doBudgetReduzieren(int item) {
		switch(item) {
			case FACEBOOK:
				setBudget(getBudget() - 50);
				break;
			case WEBSITE:
				setBudget(getBudget() - 100);
				break;
			case STEPSTONE:
				setBudget(getBudget() - 250);
				break;
			case TWITTER:
				setBudget(getBudget() - 50);
				break;
			case XING:
				setBudget(getBudget() - 100);
				break;
			case HEADHUNTER:
				setBudget(getBudget() - 500);
				break;
		}
	}
	
	public boolean isBudgetAusreichend(int item) {
		switch(item) {
		case FACEBOOK:
			return budget >= 50;
		case WEBSITE:
			return budget >= 100;
		case STEPSTONE:
			return budget >= 150;
		case TWITTER:
			return budget >= 50;
		case XING:
			return budget >= 100;
		case HEADHUNTER:
			return budget >= 500;
		}
		return false;
	}
		
	public String getItemText(int item) {
		switch(item) {
		case FACEBOOK:
			return "facebook";
		case WEBSITE:
			return "Website";
		case STEPSTONE:
			return "Stepstone";
		case TWITTER:
			return "TWITTER";
		case XING:
			return "XING";
		case HEADHUNTER:
			return "Headhunter";
		}
		return " ";
	}
	
	public String getImageUrl(int item) {
		switch(item) {
		case FACEBOOK:
			return "/img/facebook.png";
		case WEBSITE:
			return "/img/website.png";
		case STEPSTONE:
			return "/img/stepstone.png";
		case TWITTER:
			return "/img/twitter.png";
		case XING:
			return "/img/xing.png";
		case HEADHUNTER:
			return "/img/headhunter.jpg";
		}
		return "";
	}

}
